$(function () {

});

function searchData() {
    var table = layui.table, layer = layui.layer;

    table.init('serviceTable',{
        data: [
            {
                id:1,
                "LXDH": "13458978015",
                "YHZH": "80010001535915590",
                "HZSFZ": "440224198405032060",
                "HZXM": "谭燕芳",
                "PKHSX": "五保户贫困,无劳动能力户,残疾户",
                "SFSNH": "否",
                "GXSJ": "20180730145618",
                "SFDSZN": "否",
                "KHYH": "仁化县农村信用合作联社桥北分社"
            }
        ]
        , toolbar: true
        , title: '贫困户基本资料'
        , page: true
    });

    //监听行工具事件
    table.on('tool(serviceTable)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
        var data = obj.data //获得当前行数据
            , layEvent = obj.event; //获得 lay-event 对应的值

        if (layEvent === 'detail') {
            loadDetail(data.id)
        }
    });
}

function loadDetail(id) {
    var data = [
        {
            id:1,
            "LXDH": "13458978015",
            "YHZH": "80010001535915590",
            "HZSFZ": "440224198405032060",
            "HZXM": "谭燕芳",
            "PKHSX": "五保户贫困,无劳动能力户,残疾户",
            "SFSNH": "否",
            "GXSJ": "20180730145618",
            "SFDSZN": "否",
            "KHYH": "仁化县农村信用合作联社桥北分社"
        }
    ];


    var data0 = data[parseInt(id) - 1]
    $('#detailD').html(template('detailDS',{data:data0}));
    layer.open({
        type: 1,
        content: $("#detail"),
        area: ['900px', '550px'],
        title: '贫困户基本资料详情',
        maxmin: true,
        shade: 0,
        cancel: function () {
            $("#detail").hide()
        }
    });


}